package com.数据结构;

public class MylinkedList {
    private Node first;
    private int size;

    public void addFirst(Object o){
        Node n = new Node(o);
        if(size == 0){
            this.first = n;
            size++;
        }else {
            n.setNext(first);
            this.first = n;
            size ++;
        }
    }
    public void add(Object o){
        Node n = new Node(o);
        Node temp = first;
        while(temp.getNext() != null){
            temp = temp.getNext();
        }
        temp.setNext(n);
        size += 1;
    }

}

class Node{

    private Object o;
    private Node next;

    public void setO(Object o) {
        this.o = o;
    }

    public void setNext(Node next) {
        this.next = next;
    }

    public Object getO() {
        return o;
    }

    public Node getNext() {
        return next;
    }

    public Node(Object o) {
        this.o = o;
    }
}
